//
//  YDMainViewController.m
//  YDAlertShow
//
//  Created by James on 16/5/8.
//  Copyright © 2016年 bearbaby. All rights reserved.
//

#import "YDMainViewController.h"
#import "ViewController.h"
@interface YDMainViewController ()<UITableViewDataSource,UITableViewDelegate>
@property(nonatomic,strong)UITableView *tableView;
@property(nonatomic,strong)NSMutableArray *dataArr;
@property(nonatomic,strong)NSMutableArray *detailArr;
@end

@implementation YDMainViewController
-(UITableView *)tableView{

    if (!_tableView) {
        _tableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 0,YDMain_width , self.view.height) style:(UITableViewStylePlain)];
        _tableView.delegate = self;
        _tableView.dataSource = self;
        _tableView.tableFooterView = [[UIView alloc]init];
        _tableView.backgroundColor = [UIColor colorWithHexString:@"ececec"];
    }
    return _tableView;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    self.title = @"提示框";
    self.view.backgroundColor = [UIColor magentaColor];
    [self.view addSubview:self.tableView];
   // self.automaticallyAdjustsScrollViewInsets = NO;
}
#pragma mark -- tableView delegate
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{

    return self.dataArr.count;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{

    NSArray *subArr = [NSArray arrayWithArray:self.dataArr[section]];
    return subArr.count;
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{

    return 50;
}
-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{

    return 10;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{

    static NSString *identifier = @"YDCell";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier];
    if (!cell) {
        cell = [[UITableViewCell alloc]initWithStyle:(UITableViewCellStyleValue1) reuseIdentifier:identifier];
        cell.textLabel.font = [UIFont systemFontOfSize:15];
    }
    cell.textLabel.text = self.dataArr[indexPath.section][indexPath.row];
   // cell.detailTextLabel.text = self.detailArr[indexPath.section];
    return cell;
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{

    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    if (indexPath.section==0) {
        void(^handle1)() = ^(){NSLog(@"按钮1的点击时间");};
        void(^handle2)() = ^(){NSLog(@"按钮2  的点击事件");};
        [YDAlertShow showAlertWithTitle:@"寡妇" withContent:@"黑夜就是我的面纱，薇恩说的" withActions:@[handle1,handle2]];
    }else if (indexPath.section==1){
        if(indexPath.row==0){
        void(^handle1)() = ^(){NSLog(@"按钮1的点击事件");};
        void(^handle2)() = ^(){NSLog(@"按钮2 的点击事件");};
        [YDAlertShow showAlertWithTitle:@"表情提示框" withIconStatue:IconStatueError withContent:@"出来就是个错误，啦啦啦啦啦" withButtonTitles:@[@"按钮1",@"按钮2"] withButtonAction:@[handle1,handle2]];
        }else if (indexPath.row==1){
            void(^handle1)() = ^(){NSLog(@"按钮1的点击事件");};
            void(^handle2)() = ^(){NSLog(@"按钮2 的点击事件");};
            [YDAlertShow showAlertWithTitle:@"表情提示框" withIconStatue:IconStatueConfirm withContent:@"恭喜你已经完成了遨游之旅，啦啦啦啦啦" withButtonTitles:@[@"按钮1",@"按钮2"] withButtonAction:@[handle1,handle2]];
        }else if (indexPath.row==2){
            void(^handle1)() = ^(){NSLog(@"按钮1的点击事件");};
            void(^handle2)() = ^(){NSLog(@"按钮2 的点击事件");};
            [YDAlertShow showAlertWithTitle:@"表情提示框" withIconStatue:IconStatueFailure withContent:@"不好意思，你走不完了，啦啦啦啦啦" withButtonTitles:@[@"按钮1",@"按钮2"] withButtonAction:@[handle1,handle2]];
        }else if (indexPath.row==3){
            void(^handle1)() = ^(){NSLog(@"按钮1的点击事件");};
            void(^handle2)() = ^(){NSLog(@"按钮2 的点击事件");};
            [YDAlertShow showAlertWithTitle:@"表情提示框" withIconStatue:IconStatueSuccess withContent:@"恭喜你已经成为了华航最高层，啦啦啦啦啦" withButtonTitles:@[@"按钮1",@"按钮2"] withButtonAction:@[handle1,handle2]];
        }
    }else if (indexPath.section==2){
    
      __block  YDAlertShow *aletShow = [[YDAlertShow alloc]initWithTitle:@"输入框" withPlaceholder:@"想输入就输入什么" withButtonTitles:@[@"按钮1",@"按钮2"] withConfirmHandle:^{
            NSLog(@"input:%@",aletShow.inputField.text);
        }];
    }else if (indexPath.section==3){
    [YDAlertShow showAlertWithTitle:@"提示框" withContent:@
     "我寄愁心与明月，随军知道耶郎溪"];
    }else if (indexPath.section==4){
    
        if(indexPath.row==0){
                [YDAlertShow showAlertWithTitle:@"于心月" withIconStatue:(IconStatueError) withContent:@"苍天呀，又错了，还让不让人活了"];
        }
        else if (indexPath.row==1){               [YDAlertShow showAlertWithTitle:@"心愿吧" withIconStatue:(IconStatueConfirm) withContent:@"答对一次不容易呀，你说那"];
        }else if (indexPath.row==2){
                [YDAlertShow showAlertWithTitle:@"心机啦u无聊的" withIconStatue:IconStatueFailure withContent:@"人这一生失败中能有几次"];
        }else if (indexPath.row==3){
                [YDAlertShow showAlertWithTitle:@"捷克罗姆" withIconStatue:IconStatueSuccess withContent:@"这就是人生，一次次的失败积累成功"];
        }
    }
}
#pragma mark -- 初始化数据
-(NSMutableArray *)dataArr{
    
    if (!_dataArr) {
        _dataArr = @[@[@"带标题内容的提示框"],
  @[@"带标题和图片的提示框1",@"带标题和图片的提示框2",@"带标题和图片的提示框3",@"带标题和图片的提示框4"],
  @[@"带输入的提示框"],
  @[@"仅仅提示内容"],
  @[@"仅仅提示图片内容1",@"仅仅提示图片内容2",@"仅仅提示图片内容3",@"仅仅提示内容4"]].mutableCopy;
    }
    return _dataArr;
}
-(NSMutableArray *)detailArr{

    if (!_detailArr) {
        _detailArr = @[@"",@"",@"",@""].mutableCopy;
    }
    return _detailArr;
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
